fuchsia: clean up module#5127
Conversation
399a0a5 to
cc9e351
Compare
cc9e351 to
ddbf270
Compare
This comment has been minimized.
This comment has been minimized.
ddbf270 to
3783462
Compare
This comment has been minimized.
This comment has been minimized.
|
CI actually passes. There seems to be an issue with a glob import that is not used, but this has not |
3783462 to
53b65df
Compare
This comment has been minimized.
This comment has been minimized.
|
@rustbot blocked Like other deprecations, holding off until we can actually give the users an alternative. |
|
(https://snoozeth.is/db3wDy9dFKA) I will wait until Wed, 19 Aug 2026 08:31:22 UTC and then add label S-waiting-on-review and remove label S-blocked. @rustbot claim. |
53b65df to
b8d548c
Compare
This comment has been minimized.
This comment has been minimized.
|
There's some problems in Fuchsia. Each vendored libc implementation has a different implementation. Sometimes they can be unified. Other times it's not possible. An example of the latter is Should I also expose |
5d7d0ae to
48d5e6a
Compare
This comment has been minimized.
This comment has been minimized.
66e4bed to
dd07b99
Compare
off64_t type in Fuchsia70bef1c to
48d1e3d
Compare
416f276 to
0b8b2e6
Compare
This comment has been minimized.
This comment has been minimized.
35c2504 to
29b5331
Compare
29b5331 to
2b8b9da
Compare
This comment has been minimized.
This comment has been minimized.
|
|
||
| // From psABI Calling Convention for RV64 | ||
| pub type __u64 = c_ulonglong; | ||
| pub type wchar_t = i32; |
There was a problem hiding this comment.
Commit "fuchsia: mirror type aliases": it looks like wchar_t was i32 on rv64 and x86, but u32 on aarch64 so they probably shouldn't be combined
There was a problem hiding this comment.
Fair. But there's something to be noted here. wchar_t is always defined in terms of __WCHAR_TYPE__. This type does not seem to appear anywhere in the Fuchsia tree [1]. I haven't had a way of verifying if the current definitions are correct.
There was a problem hiding this comment.
That one comes from the compiler, search for __WCHAR_TYPE__ at https://c.godbolt.org/z/efjeK48j5. So I believe the existing definitions are correct.
| pub union fpos_t { | ||
| __opaque: [c_char; 16], | ||
| __align: c_double, | ||
| } |
There was a problem hiding this comment.
Commit "fuchsia: fill in definition of fpos_t": LGTM @ d8710c0.
There was a problem hiding this comment.
Commit "fuchsia: deprecate nonexistent types": LGTM @ 9ace3f9
| pub struct sem_t { | ||
| __val: [c_int; 8], | ||
| pub _s_value: c_int, | ||
| pub _s_waiters: c_int, | ||
| } | ||
|
|
||
| #[repr(align(8))] | ||
| pub struct siginfo_t { | ||
| pub si_signo: c_int, | ||
| pub si_errno: c_int, | ||
| pub si_code: c_int, | ||
| pub _pad: [c_int; 29], | ||
| _align: [usize; 0], | ||
| pub __si_fields: [c_int; 28], | ||
| } |
There was a problem hiding this comment.
Ditto, the new fields here can remain private unless somebody shows up with a need for them
| pub struct utsname { | ||
| pub sysname: [c_char; 65], | ||
| pub nodename: [c_char; 65], | ||
| pub nodename: [c_char; crate::HOST_NAME_MAX.cast_unsigned() as usize + 1], |
| pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { | ||
| let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc | ||
| let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); | ||
| cpuset.bits[idx] |= 1 << offset; | ||
| () | ||
| pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> c_ulonglong { | ||
| (cpu / 8 >= size_of::<crate::cpu_set_t>()) | ||
| .then_some(0) | ||
| .unwrap_or_else(|| { | ||
| let c = &mut cpuset.__bits[cpu / 8 / size_of::<c_long>()]; | ||
| *c |= 1 << (cpu % (8 * size_of::<c_long>())); | ||
|
|
||
| *c | ||
| }) | ||
| } | ||
|
|
||
| pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { | ||
| let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc | ||
| let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); | ||
| cpuset.bits[idx] &= !(1 << offset); | ||
| () | ||
| pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> c_ulonglong { | ||
| (cpu / 8 >= size_of::<crate::cpu_set_t>()) | ||
| .then_some(0) | ||
| .unwrap_or_else(|| { | ||
| let c = &mut cpuset.__bits[cpu / 8 / size_of::<c_long>()]; | ||
| *c &= !(1 << (cpu % (8 * size_of::<c_long>()))); | ||
|
|
||
| *c | ||
| }) | ||
| } |
There was a problem hiding this comment.
I don't think these are supposed to return values, or at least that's more of an implementation detail than something we need to show. Per https://man7.org/linux/man-pages/man3/CPU_SET.3.html they're treated as void functions.
| (cpu / 8 >= size_of::<crate::cpu_set_t>()) | ||
| .then_some(false) | ||
| .unwrap_or_else(|| { | ||
| (cpuset.__bits[cpu / 8 / size_of::<c_long>()] | ||
| & (1 << (cpu % (8 * size_of::<c_long>())))) | ||
| != 0 | ||
| }) |
There was a problem hiding this comment.
then/then_some tends to obfuscate control flow, just use if.
There was a problem hiding this comment.
Commit "fuchsia: fix bits/signal.h types": LGTM @ 33d311a, but should wait on a maintainer to test ideally.
Note: when you link on codesearch, use l-r or links->commit to get a permalink in case sources move around.
Fixes `fd_set`'s array field. The size was wrong [1]. Now unused constants have been removed. The PR has been separated from the commit fixing miscellaneous records. [1]: https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/third_party/ulib/musl/include/sys/select.h;l=23-25
Mirror type aliases. They were previously only equivalent. This changes them to using C types. Remove architecture-specific definitions. They were the same.
2b8b9da to
fda5b07
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Mirror constants. They were previously equivalent.
Fills in the pending definition. It's opaque in other platforms. It's public in the Fuchsia headers [1]. Solves a `FIXME`. [1]: https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/third_party/ulib/musl/include/stdio.h;l=47-50
Remove nonexistent types. They are not part of the Fuchsia SDK. Replace `off64_t` in two routines. It's now `off_t`. `off64_t` has never existed in Fuchsia.
2b3cffc to
4fbda85
Compare
Remove uses of 32-bit target conditional compilation. Fuchsia does not support 32-bit targets [1]. This is unnecessary. Fix missing fields in records. No particular header file is targetted. All wrong records have been fixed. c.f. all headers under `sysroot/include` in the SDK. Fix `cpu_set_t` macros [2]. They were wrongly defined. They neither returned the right values. [1]: https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs/0111_fuchsia_hardware_specifications#required_64-bit_cpu_and_platform [2]: https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/third_party/ulib/musl/include/sched.h
Fix definition of types in x86_64. `mcontext_t` provided opaque field. `ucontext_t` had a slightly wrong definition. New records have been introduced. They are particular to `mcontext_t`. Add definitions in AArch64 and RISC-V64. They were missing. They are different for all three target architectures. These are declared in [1]. [1]: https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/third_party/ulib/musl/include/bits/signal.h
Remove opaque types. Replace with proper fields.
Remove conditional defintion for 32-bit targets. Fuchsia has no 32-bit
targets.
Static initializers needed modification. They are specified as `{ 0 }`
in POSIX for C. The new definition replicates that. It zeroes/nullifies
the new fields. Constants were used to initialize the previous opaque
array. These have been deprecated.
These are declared in [1].
[1]: https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/third_party/ulib/musl/include/pthread.h
4fbda85 to
12715e9
Compare
Description
This is a clean-up patch. Changes are concerned with the
fuchsiamodule.There were lacking definitions. There were records with the wrong alignment. There were types that don't exist upstream. This has been fixed. But there's more stuff to fix.
Testing is pending. This time testing is required. Two supported Fuchsia targets are tier 2. There's no CI job for them.
Sources
Paths are relative to the downloadable SDK. Look under the
objdirectory. Changes have been made relative to allNEXTreleases.wchar_tis not different across architectures. No specific definition was found. Verifying the current definition was not possible.nlink_tis not different across architectures.blksize_tis not different across architectures.ssizet_thad a wrong definition. Other_t-terminated types had similar issues. Those will not be further repeated in this list.cs.opensource.google. This includes suffixed offset types. These are omitted from further mention.stathad a mismatched definition.glob_thad a mismatched definition.signal.htypes often had a mismatched definition. This header file appears later on in this source list. They refer to different paths. They contain different definitions.siginfo_t.sigevent.sigaction.SIG_DFLand others are function pointers. They are cast to function pointers from integers. They are sometimesNULL. This is not allowed in Rust. I have wrapped them inOption. They are allNonenow. They should not all beNone. Transmutation from a pointer without provenance to a function pointer is required. This causes compile-time errors.stat64doesn't exist.ipc_permdoesn't exist.epoll_datadoesn't exist. Deprecation lints here keep popping up. I've attempted to silence them. My attempts have been futile.epoll_eventdoesn't exist.ff_effectdoesn't exist.termios2doesn't exist.sysinfodoesn't exist.mq_attrdoesn't exist.sockaddr_nldoesn't exist.RLIM_SAVED_MAXdoesn't exist.RLIM_SAVED_CURdoesn't exist.RLIM_INFINITYdoesn't exist.RLIMIT_RTTIMEdoesn't exist.RLIMIT_NLIMITSdoesn't exist.There were conditional checks against 32-bit targets. Rust does not support 32-bit Fuchsia targets. The Fuchsia project does not support 32-bit machine word targets.
There was an oddity with
pthread.htypes. They were defined with a single field. This field sometimes had size equivalent to the sum of upstream fields. This has been replaced with the real fields. This has also fixed some size and alignment mismatches.This has required changes in macros. An attempt has been made to fit the POSIX definitions. This means expanding
staticinitializers to{ 0 }. The new type definitions get all their fields zeroed. Some are made into null pointers. Should they be made intoOption::Nones? They are not function pointer fields.Macros needed fixing. Their definition did not return a value. But a value was returned upstream. Some types needed small fixes.
m_contexthad a mismatched definition. Some modules didn't have a definition.u_contexthad a mismatched definition. Some modules didn't have a definition.Checklist
libc-test/semverhave been updated*LASTor*MAXare included (see #3131)cd libc-test && cargo test --target mytarget); especially relevant for platforms that may not be checked in CI@rustbot label +stable-nominated